<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function getImgUrl(imgUrl) {
            // if (imgUrl == undefined || imgUrl == '' || imgUrl == null) {
            //     return 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png'
            // } else {
            //     return imgUrl
            // }

            return url ? url : 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png'
        }

        var r = getImgUrl('xxx.png')//->xxx.png
        console.log(r);
        var r2 = getImgUrl();//->得到一个默认的图片地址
        console.log(r2);


        // var url = 'xxx.png'
        var url = undefined;
        // 只要url有内容 就会转为true 就执行 式子1
        var newUrl = url ? url : 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png'
        console.log(newUrl);
    </script>

</body>

</html>